/**
 * Project Name:trustsql-idm-demo
 * File Name:DemoApplication.java
 * Package Name:com.tencent.trustsql.idm.demo
 * Date:2018年1月17日下午5:41:59
 * Copyright (c) 2018, Tencent All Rights Reserved.
 *
*/

package com.tencent.trustsql.idm.demo;

import com.tencent.trustsql.idm.demo.util.RequestUtil;
import com.tencent.trustsql.idm.demo.util.SimpleHttpClient;
import com.tencent.trustsql.sdk.TrustSDK;
import com.tencent.trustsql.sdk.bean.PairKey;

/**
 * ClassName:DemoApplication <br/>
 * Date:     2018年1月17日 下午5:41:59 <br/>
 * @author   ronyyang
 * @version  
 * @since    JDK 1.7
 * @see 	 
 */
public class DemoApplication {

	public static void main(String[] args) throws Exception {

		//生成公私钥
//		PairKey pair = TrustSDK.generatePairKey(true);
//		System.out.println("公钥:"+pair.getPublicKey());
//		System.out.println("私钥:"+pair.getPrivateKey());

		//公钥
		String publicKey = "AttKPLaTisB35xEHTpjxzrMQXj72F7oLJZYfEBqYXZ8Z";
		//私钥
		String privateKey = "2r5KM0GFlyVJaZzyDVh2fCzwNykyjINJDTUFQKgMStw=";

		//通过私钥生成公钥
//		String publicKey2 = TrustSDK.generatePubkeyByPrvkey(privateKey,true);
//
//		System.out.println("通过私钥生成公钥："+publicKey2);

		//通过公钥生成地址
//		String address = TrustSDK.generateAddrByPubkey(publicKey);
//
//		System.out.println("公钥生成地址:"+address);


		//通过私钥生成地址
//		String address = TrustSDK.generateAddrByPrvkey(privateKey);
//
//		System.out.println("私钥生成地址:"+address);


		//验证公私钥是否匹配
//		boolean isMatch = TrustSDK.checkPairKey(privateKey,publicKey);
//
//		System.out.println("是否匹配："+isMatch);



		//生成签名
//		String signString = TrustSDK.signString(privateKey,"Tencent TrustSQL".getBytes("UTF-8"),false);
//		System.out.println("签名："+signString);

		//注册用户
//		String request = RequestUtil.generateRegisterUserRequest();
//		SimpleHttpClient httpClient = new SimpleHttpClient();
//		String result = httpClient.post("https://baas.trustsql.qq.com/idm_v1.1/api/user_cert/register", request);
//		System.out.println(result);

		//获取用户信息
//		String request = RequestUtil.generateQueryAllAccountRequest();
//		System.out.println("request=="+request);
//		SimpleHttpClient httpClient = new SimpleHttpClient();
//		String result = httpClient.post("https://baas.trustsql.qq.com/idm_v1.1/api/user_cert/fetch", request);
//		System.out.println(result);

		//创建用户账户
//		String request = RequestUtil.generateRegisterAccountRequest();
//		SimpleHttpClient httpClient = new SimpleHttpClient();
//		String result = httpClient.post("https://baas.trustsql.qq.com/idm_v1.1/api/account_cert/register", request);
//		System.out.println(result);

		//资产发行申请
//		String request = RequestUtil.generateAssetsApplyRequest();
//
//		System.out.println(request);
//		SimpleHttpClient httpClient = new SimpleHttpClient();
//		String result = httpClient.post("https://baas.trustsql.qq.com/cgi-bin/v1.0/dam_asset_issue_apply_v1.cgi", request);
//		System.out.println(result);

	}

}

